home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Collision Detects !!!!
- References: <4je2ks$a05@ftp.man.szczecin.pl>
- X-Newsreader: TIN [version 1.2 PL2]
- Path: imada.ou.dk!breese
- From: breese@imada.ou.dk (Bjorn Reese)
- Message-ID: <1996Mar30.173102.10460@imada.ou.dk>
- Sender: news@imada.ou.dk
- Nntp-Posting-Host: wagner.imada.ou.dk
- Organization: Dept. of Math. & Computer Science, Odense University, Denmark
- Date: Sat, 30 Mar 1996 17:31:02 GMT
- Newsgroups: comp.sys.amiga.programmer
-
- Cezary Kobylinski (amigos@safona.tuniv.szczecin.pl) wrote:
- > I want to know what is the best method to detect collision between any
- > bobs ?!
-
- Use coordinate check as a quick and approximate detection.
-
- 0) Assign a square to each object so that all pixels of the
- object are within the square.
-
- 1) Check if the squares of two objects overlaps with each other.
-
- 2) If there was an overlap (and if you want more accuracy) apply
- the blitter check or a similar mask check.
-
- Assuming that (xpos,ypos) is the upper left corner of the bob,
- it could look something like this (must be done for each pair
- of a's an b's)
-
- if (a->flags.solid &&
- (a->xpos < b->xpos + b->xsize) &&
- (a->xpos + a->xsize > b->xpos ) &&
- (a->ypos < b->ypos + b->ysize) &&
- (a->ypos + a->ysize > b->ypos )) {
- /* Overlap */
- }
-
- --
- Bjorn Reese Email: breese@imada.ou.dk
- Odense University, Denmark URL: http://www.imada.ou.dk/~breese
-
- "It's getting late in the game to show any pride or shame" - Marillion
-